Fix: Support placeholders in header replacement search patterns#7117
Merged
mholt merged 3 commits intocaddyserver:masterfrom Jul 14, 2025
Merged
Conversation
…tion - Skip regex compilation during provision when placeholders are detected - Compile regex at runtime after placeholder replacement - Preserves performance for static regexes while enabling dynamic placeholders - Fixes caddyserver#7109
- Test containsPlaceholders function edge cases - Test provision skips compilation for dynamic regexes - Test end-to-end placeholder replacement functionality
…/zongzewu23/caddy into fix/header-placeholder-find-7109
mholt
approved these changes
Jul 14, 2025
Member
mholt
left a comment
There was a problem hiding this comment.
This actually looks pretty good; thanks for the tests as well.
Shall we give this a try?
Contributor
Author
|
Thanks for the review and merge! |
kamran-raei
pushed a commit
to kamran-raei/caddy
that referenced
this pull request
Jul 16, 2025
…rver#7117) * fix: resolve http.request placeholders in header directive find operation - Skip regex compilation during provision when placeholders are detected - Compile regex at runtime after placeholder replacement - Preserves performance for static regexes while enabling dynamic placeholders - Fixes caddyserver#7109 * test: add tests for placeholder detection in header replacements - Test containsPlaceholders function edge cases - Test provision skips compilation for dynamic regexes - Test end-to-end placeholder replacement functionality
1 task
mohammed90
pushed a commit
to cedricziel/caddy
that referenced
this pull request
Aug 29, 2025
…rver#7117) * fix: resolve http.request placeholders in header directive find operation - Skip regex compilation during provision when placeholders are detected - Compile regex at runtime after placeholder replacement - Preserves performance for static regexes while enabling dynamic placeholders - Fixes caddyserver#7109 * test: add tests for placeholder detection in header replacements - Test containsPlaceholders function edge cases - Test provision skips compilation for dynamic regexes - Test end-to-end placeholder replacement functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7109
This PR enables the use of placeholders (e.g.,
{http.request.local.port}) in the search patterns of header replacement operations.Problem:
Previously, placeholders in search patterns were compiled as literal regex during provision, before placeholder resolution could occur at runtime.
Solution:
Testing: